import asyncio

from api_utils.base_data_api import BaseDate, get_user_info
from database.models.user_model import UserData


class UserOperation:

    @staticmethod
    def handle_user_info():
        base_data = BaseDate()
        response = asyncio.run(get_user_info(base_data))
        if response.message != "success":
            return False
        all_user_data = response.data
        UserData.insert_user_info(all_user_data)

    @staticmethod
    def get_user_id_list():
        base_data = BaseDate()
        response = asyncio.run(get_user_info(base_data))
        new_uid_list = []
        if response.message != "success":
            print("用户信息获取失败")
        all_user_data = response.data
        for user in all_user_data:
            uid = user.get("uid")
            new_uid_list.append(uid)
        return new_uid_list


if __name__ == '__main__':
    UserOperation.handle_user_info()
